/**
 * <copyright>
 * </copyright>
 *

 */
package de.rwth.adroidGuiLang.impl;

import de.rwth.adroidGuiLang.AdroidGuiLangPackage;
import de.rwth.adroidGuiLang.Colors;
import de.rwth.adroidGuiLang.TwoColumnBox;
import de.rwth.adroidGuiLang.TwoColumnLine;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Two Column Box</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.rwth.adroidGuiLang.impl.TwoColumnBoxImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link de.rwth.adroidGuiLang.impl.TwoColumnBoxImpl#getColor <em>Color</em>}</li>
 *   <li>{@link de.rwth.adroidGuiLang.impl.TwoColumnBoxImpl#getElements <em>Elements</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TwoColumnBoxImpl extends BoxImpl implements TwoColumnBox
{
  /**
   * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected static final String DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected String description = DESCRIPTION_EDEFAULT;

  /**
   * The default value of the '{@link #getColor() <em>Color</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getColor()
   * @generated
   * @ordered
   */
  protected static final Colors COLOR_EDEFAULT = Colors.NULL;

  /**
   * The cached value of the '{@link #getColor() <em>Color</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getColor()
   * @generated
   * @ordered
   */
  protected Colors color = COLOR_EDEFAULT;

  /**
   * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getElements()
   * @generated
   * @ordered
   */
  protected EList<TwoColumnLine> elements;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected TwoColumnBoxImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AdroidGuiLangPackage.Literals.TWO_COLUMN_BOX;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDescription()
  {
    return description;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDescription(String newDescription)
  {
    String oldDescription = description;
    description = newDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AdroidGuiLangPackage.TWO_COLUMN_BOX__DESCRIPTION, oldDescription, description));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Colors getColor()
  {
    return color;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setColor(Colors newColor)
  {
    Colors oldColor = color;
    color = newColor == null ? COLOR_EDEFAULT : newColor;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AdroidGuiLangPackage.TWO_COLUMN_BOX__COLOR, oldColor, color));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<TwoColumnLine> getElements()
  {
    if (elements == null)
    {
      elements = new EObjectContainmentEList<TwoColumnLine>(TwoColumnLine.class, this, AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS);
    }
    return elements;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS:
        return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__DESCRIPTION:
        return getDescription();
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__COLOR:
        return getColor();
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS:
        return getElements();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__DESCRIPTION:
        setDescription((String)newValue);
        return;
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__COLOR:
        setColor((Colors)newValue);
        return;
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS:
        getElements().clear();
        getElements().addAll((Collection<? extends TwoColumnLine>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__DESCRIPTION:
        setDescription(DESCRIPTION_EDEFAULT);
        return;
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__COLOR:
        setColor(COLOR_EDEFAULT);
        return;
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS:
        getElements().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__DESCRIPTION:
        return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__COLOR:
        return color != COLOR_EDEFAULT;
      case AdroidGuiLangPackage.TWO_COLUMN_BOX__ELEMENTS:
        return elements != null && !elements.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (Description: ");
    result.append(description);
    result.append(", color: ");
    result.append(color);
    result.append(')');
    return result.toString();
  }

} //TwoColumnBoxImpl
